<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'addClass.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<LINK href="<%=basePath%>/css/main.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
		
function CheckForm()
{
   if(document.getElementById("picTitle").value=="")
   { alert("标题不能为空！");
     return (false);
   }
   var fileName = document.getElementById("img2").value;
   var pos = fileName.lastIndexOf(".");

   var lastname = fileName.substring(pos+1,fileName.length);

   var tp ="jpg,gif,bmp,JPG,GIF,BMP,png,PNG";    
   var rs=tp.indexOf(lastname);

   if(rs>=0){
   	return true;
   }else{
   	alert("文件格式不对，请上传jpg、gif、png、bmp格式的图片！");
    return false;
   }
   
}

function test(){
	var img =document.getElementById("img");
	var url = document.getElementById("img2").value;
	img.src=url;
}

</script>

</head>

<body>
<TABLE class=small cellSpacing=0 cellPadding=3 width="100%" border=0>
	<TBODY>
		<TR>
			<TD class=Big><IMG src="<%=basePath%>/img/office/address.gif"
				align=absMiddle><SPAN class=big3>&nbsp; 添加图片 </SPAN></TD>
		</TR>
		<tr>
			<td style="padding-left: 140px;"><font color="red">&nbsp;
			温馨提示：只能上传jpg\gif\png\bmp等常见格式的图片，最适规格:200*115左右</font></td>
		</tr>
	</TBODY>
</TABLE>

<form action="<%=basePath%>RollPicServlet?action=add" method="post"
	enctype="multipart/form-data" onsubmit="return CheckForm();">
<table class="TableBlock" width="750" align="center">

	<tr align="center">
		<td class="TableData"><a>标题：</a></td>
		<td class="TableData" align="left"><input type="text" id="title"
			name="picTitle" size="50"></td>

	</tr>
	<tr align="center" id="tr">
		<td class="TableData"><a>图片预览：</a></td>
		<td class="TableData"><img id="img" width="200" height="150">
		</td>

	</tr>
	<tr align="center">
		<td class="TableData"><a>图片路径：</a></td>
		<td class="TableData"><input type="file" name="picURL" id="img2"
			onchange="test()" size="40"></td>

	</tr>
	<tr align="center">

		<td colspan="2" class="TableData" align="center"><input
			type="submit" class="SmallButton" value="确定"> <input
			type="button" class="SmallButton" value="返回"
			onclick="javascript:history.go(-1);"></td>

	</tr>

</table>
</form>
</body>

</html>
